package assets_withdraw

import (
	"context"

	"gitee.com/liuxuezhan/ar-platform/admin-api/internal/svc"
	"gitee.com/liuxuezhan/ar-platform/admin-api/internal/types"
	"gitee.com/liuxuezhan/ar-platform/base-common/tool/wlog"
	"gitee.com/liuxuezhan/ar-platform/rpc-client/assetsClient/rpc"
	"github.com/jinzhu/copier"
	"github.com/zeromicro/go-zero/core/logx"
)

type AssetsWithDrawTypeUpdateLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

// b端提现管理--提现配置--增加修改
func NewAssetsWithDrawTypeUpdateLogic(ctx context.Context, svcCtx *svc.ServiceContext) *AssetsWithDrawTypeUpdateLogic {
	return &AssetsWithDrawTypeUpdateLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *AssetsWithDrawTypeUpdateLogic) AssetsWithDrawTypeUpdate(req *types.AssetsWithDrawTypeUpdateReq) (resp *types.AssetsWithDrawTypeUpdateRes, err error) {
	// todo: add your logic here and delete this line
	rpc_req := &rpc.UpdateWithDrawTypeRequest{
		WithDrawType: &rpc.WithDrawType{},
	}
	copier.Copy(rpc_req.WithDrawType, req)

	// 发送请求
	rpc_resp, err := l.svcCtx.AssetsRpc.PayWithdraw.WithdrawTypeUpdate(l.ctx, rpc_req)
	if err != nil {
		wlog.Handle.Errorf(l.ctx, "Call ModifyVipLevelInfos error: %v", err)
		return nil, err
	}

	// 处理请求返回的结果
	// 解析、组合数据
	resp = &types.AssetsWithDrawTypeUpdateRes{}

	if rpc_resp.Data != nil {
		copier.Copy(resp.WithDrawType, rpc_resp.Data)
	}
	return
}
